Hi, |
Re: Problem in sorting attributes I'd define new_Enum at the same time as the old, and populate its values at the same time, then sort the new.
NitPick: Golly, it was so many years ago when I did this, but: I proved that if you want to sort an array that was not in random order you could save a lot of sort time by having two internal loops. The first swap-loop goes from 1-to-size like you have it, but its then followed by a second swap-loop goes from size-to-1. Since that will always put the lowest value at the bottom and the highest value at the top, you can restrict the loops by [1] 1+Nums-To-(Size-Nums) and [2] (Size-Nums)-to-1+Nums, where Nums was the number of times you've done these loops. Also, the outer loop should be some sort of 'do while(! Done)', setting Done true at the top but setting it false whenever you actually do a swap. With this algorithm, if someone inserted an Enum in the wrong spot (its 'almost' sorted), the sort loop only makes one pass. Woopee. Forget all that, use the "void sort(string stringArray[])" function. |